#include <iostream>
#include <cstdio>
#include <cstring>

int n;
int d[110][110],a[110][110];

int max(int x,int y)
{
    return x>y?x:y;
}

int main()
{
    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for (int i = 1; i<=n ; i++)
        for (int j = 1; j<=i ; j++)
            scanf("%d",&a[i][j]);
    for (int j=1;j<=n;j++)
        d[n][j] = a[n][j];
    for (int i=n-1;i>=1;i--)
        for (int j=1;j<=i;j++)
            d[i][j] = a[i][j] +max(d[i+1][j],d[i+1][j+1]);
    printf("%d",d[1][1]);
}
